#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
	static bool cmp(vector<int>& a, vector<int>& b)
	{
		return a[0] < b[0];
	}
	int findMinArrowShots(vector<vector<int>>& points) {
		sort(points.begin(), points.end(), cmp);
		int cnt = 1;
		int minIdx = points[0][1];
		for (int i = 1; i < points.size(); i++)
		{
			if (points[i][0] <= points[i - 1][1])
			{
				points[i][1] = min(points[i - 1][1], points[i][1]);
			}
			else
			{
				cnt++;
			}
			minIdx = min(points[i][1], points[i - 1][1]);
		}
		return cnt;
	}
};

int main()
{
	Solution A;
	//vector<vector<int>> vec{ {3, 9}, {7, 12}, {3, 8}, {6, 8},
		//{9, 10}, {2, 9}, {0, 9},{3, 9}, {0, 6}, {2, 8} };
	vector<vector<int>> vec{ {9, 12}, {1, 10}, {4, 11},
		{8, 12}, {3, 9}, {6, 9}, {6, 7} };
	cout << A.findMinArrowShots(vec) << endl;
	return 0;
}